/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bussiness;

import Connection.DBUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author SONY
 */
public class clsAdmin {
    private int stt;
    private String email;
    private String password;
    private String fullName;
    
    public clsAdmin(){
        this.stt = 0;
        this.email = null;
        this.password = null;
        this.fullName = null;
    }

    public int getStt() {
        return stt;
    }

    public void setStt(int stt) {
        this.stt = stt;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }
    
    public static Vector getAllAdmin() throws SQLException{
        Vector v = new Vector();
        String SQL = "Select * from Admin ";
        DBUtil db = new DBUtil();   
        ResultSet rs = db.executeQuery(SQL);
        while (rs.next())
        {
            clsAdmin ad = new clsAdmin();
            ad.stt = rs.getInt("Stt");
            ad.email = rs.getString("Email");
            ad.password = rs.getString("Password");
            ad.fullName = rs.getString("FullName");
            v.add(ad);
        }
        return v;
          
    }
    
    public int checkLoginAdmin(String u, String p) throws SQLException{
        Vector v = new Vector();
        v = clsAdmin.getAllAdmin();
        for (int i=0; i<v.size(); i++ )
        {
            clsAdmin a = (clsAdmin)v.get(i);
            if (a.email.equals(u) && a.password.equals(p))
                return 1;
        }
        return 0;
    }
}
